home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / SPEC S&L v.1.0.1 / Libraries / Globals.Lib < prev    next >
Encoding:
Text File  |  1993-12-17  |  17.3 KB  |  475 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        Globals.Lib
  5. #
  6. #    Contains:    xxx put contents here xxx
  7. #
  8. #    Written by:    Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
  9. #
  10. #    Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #    <1.0.112>     12/16/93    KTA        Changed gFileToolOutput to gTestCaseLoggingMethod
  19. #    <1.0.111>     12/14/93    KTA        Removed Palantino from default gFontList. 
  20. #    <1.0.110>     12/2/93    KTA        Fixed bug where it was not possible to set the randomSeed value
  21. #                                    from the Custom.Lib.
  22. #    <1.0.19>     9/23/93    KTA        Moved gPreflight from TCS.Lib so it would be initialized at the
  23. #                                    right time.
  24. #    <1.0.18>     9/22/93    KTA        Removed global gStopTimer it was not used, removed gScriptLevel
  25. #                                    from globals, removed kScrapStyledTEXT, etc.
  26. #    <1.0.17>     9/13/93    KTA        Updated TestLevel specification.
  27. #    <1.0.16>     9/10/93    KTA        Added a definable test level for application specific tests -
  28. #                                    gAppTestLevel.
  29. #    <1.0.15>      9/2/93    KTA        Fixed example in SetTestLevel()
  30. #    <1.0.14>      9/1/93    KTA        Added task ExitVU, and task reference to it - gExitVU.
  31. #    <1.0.13>     8/25/93    KTA        Added support for parity checking the TCS stack and Script
  32. #                                    parameter to set test level.
  33. #    <1.0.12>     8/20/93    KTA        Moved TCS specific Globals, added gFileToolOutput and
  34. #                                    gNoteBookOutput for FileTool output of Phoenix data.
  35. #    <1.0.11>     7/20/93    KTA        Bug Fix: I wiped out gBuildVers when fixing gIsSys7.
  36. #    <1.0.10>     7/19/93    KTA        Added customiation support: Dependancy on Custom.lib, call
  37. #                                    InitCustom().
  38. #     <1.0.9>     7/15/93    KTA        Added TCSExpCount, and made a better check for gIsSys7 (for
  39. #                                    PowerPC).
  40. #     <1.0.8>     7/14/93    KTA        Place some global variable strings into resources for
  41. #                                    international support. gScraptitle, gFontlist, gFontStyleList,
  42. #                                    gFontSizeList.
  43. #        <1+>     5/21/93    NAGA        Adding header and porting old files to follow new standards
  44. #
  45. # ****************************************************************************
  46. #
  47.  
  48. ########################################################################
  49. #                            External libraries 
  50. #=======================================================================
  51. Libraries "Custom.Lib";
  52.  
  53. #########################################################################
  54. ####################            GLOBALS                #####################
  55. #########################################################################
  56. ### Global Library Definitions
  57. ###        Generally:
  58. ###        If current value is 0 or 1, new value must be a 0 or 1
  59. ###        If current value is true or false, new value must be true or false
  60. ###        If current value is a string, new value must be a string
  61. ###        If current value is a list, new value must be a list.
  62. ###
  63. #########################################################################
  64. #########################################################################
  65. #                            InitGlobals()
  66. #========================================================================
  67. # Author:        Kevin Avoy
  68. # Description:    Initializes most global variables used by the SPEC S&L.  
  69. #                This Task should be called prior to making any calls to 
  70. #                any tasks contained within the SPEC S&L Libraries
  71. #                Please refer to 'The Hitchhikers Guide' for more information 
  72. #                concerning any individual global.
  73. # Parameters:    None
  74. # Returns:        Nothing
  75. # Examples:        InitGlobals();
  76. # Assumptions:     
  77. #========================================================================
  78. # History:
  79. # KTA    7/8/93    Added String Resources  (intl) 
  80. # KTA     7/14/93    Updated gIsSys7 check for PowerPC
  81. #########################################################################
  82. TASK InitGlobals(pTheScriptParam := -1) 
  83. begin
  84.     
  85.     ############## Misc Globals ############
  86.     global gLogLevel                  := 5;                    # Specifies the which logstr calls will be output
  87.     global gAppVerify                 := 1;                    # 1 to verify the application is expected
  88.     global gTargetCheck             := 1;                    # 1 for target title; 2 for target application title
  89.     global gTestCaseLoggingMethod     := 0;            # Output Test Case records
  90.     global gNoteBookOutput            := 1;                    # Output DataBase records to the NoteBook
  91.     global gExitVU                     :=     Task ExitVU;        # Task reference for exiting
  92.     
  93.     ############## Misc constants ############
  94.     global gDebugFlag             := 0;        # Debugging values
  95.  
  96.     global gTextStr := "How jumping gymnasts will level six piqued frogs, Jim!";
  97.  
  98.     ############## ScrapBook Constants ############
  99.     global kScrapTEXT             := 1;        # ScrapItem location of TEXT
  100.     global kScrapPICT             := 2;        # ScrapItem location of PICT
  101.     
  102.     ############## Script Globals ############
  103.     global gAliasDirectory         := "#Aliases";    # Location of Core app aliases ( found in Apple Menu )
  104.     global gDBLogging            := 1;            # Set to true to do Suite & TCS logging
  105.     global gPreFlight            := 1;            # Set to true if you want to be sure target can 
  106.                                                 # run app (see PreFlight task)
  107.     
  108.     match[target t:?machineName];
  109.     global gMachineName := machineName;
  110.  
  111.     ############## String Resources  (intl) ############
  112.     global gScrapTitle := getString(1000);    
  113.     
  114.     #======= font characteristic lists =======
  115.     global gFontList := BuildListFromResource(2000);
  116.     global gFontSizeList := BuildListFromResource(2001);
  117.     global gFontStyleList := BuildListFromResource(2002);
  118.  
  119.  
  120.     ############################################################################
  121.     # gSFPUTLocation contains the path to the directory in which files will be saved
  122.     # by the NameOK Task. If the list is empty files will be saved in the default dir
  123.     # IMPORTANT:  gSFPUTLocation is a list
  124.     # for example:  global gSFPUTLocation := {"myDisk"};
  125.     ############################################################################
  126.     global gSFPUTLocation         := {};
  127.  
  128.     ############## Print Global  ############
  129.     global gPrintTest             := 0;                    # If true print test will be executed
  130.     
  131.     ############## DoWindows Globals ############
  132.     global gDoWindowList := {1,1,1,1};
  133.         # Set each element to 1 or 0.  Flag for performing DoWindows tests as follows:
  134.         # Element:      1 - Sizing
  135.         #             2 - Scrolling
  136.         #             3 - Dragging
  137.         #             4 - Zooming
  138.  
  139.     ############## Launching/Quitting Globals ##################################
  140.         #  Quit() will close all windows, Launchtwitch() will background quit apps
  141.     global gBackgroundQuit := 0;
  142.     
  143.         # Overrides gBackgroundQuit.  Quit() does nothing, Launchtwitch() will
  144.         # twitch to and quit apps until it can complete launch.
  145.     global gForceQuit := 0;
  146.     
  147.         # Quit() will attempt to twitch to gFillMemApp and quit it. Launchtwitch(AppName)
  148.         # will attempt to launch gFillMemApp after AppName.
  149.     global gFillMemory := 0;
  150.     
  151.         # The name of the app you want to fill memory with.  Set it's memory allocation
  152.         # high enough to use up all additional memory, place it's alias in the apple menu or
  153.         # in the alias directory.
  154.     global gFillMemApp := 'TeachText';
  155.     
  156.     
  157.     ############## Random Seeding Globals ##################################
  158.     global gSeedZero := 0;        # set to 1 if seed value needs to be zero (very unlikely!)
  159.                                 # don't change unless you are sure - overrides gSeedValue!
  160.     global gSeedValue:= 0;        # set seed value if reproducing tests, otherwise leave at 0
  161.  
  162.  
  163.     ############################################################################
  164.     ####### DO NOT modify any of the following GLOBAL Settings -      ############
  165.     ####### DisableAllLogging may be reset during script execution  ############
  166.     ############################################################################
  167.     ### Updated gIsSys7 check for PowerPC
  168.     SystemCheck := Gestalt('sysv');
  169.     myError := ScriptError();
  170.     if not(SystemCheck[1]) and not(myError)
  171.     begin
  172.         SystemVersion := SystemCheck[2][2];
  173.         if (SystemVersion >= 1792)    # 1792 is 0700 in Hex for system 7.0
  174.             Global gIsSys7 := 1;     # System7 features are available
  175.         Else
  176.             gIsSys7 := 0;     # System7 features are not available
  177.     end;
  178.     else        # Gestalt may not be installed. Exit for now
  179.     begin
  180.         Println "Sorry, a gestalt error occured - ", systemCheck[1];
  181.         call (global gExitVU);
  182.     end;
  183.     match[system v:?SysName];
  184.     global gBuildVers := "{SysName}"; 
  185.     global gLogStrCount := 0;        # Initializes the counter used by LogStr
  186.     global gAppTitle := "";            # Current application title for AppVerify()
  187.     global gAppVersion := "";        # Version of current application
  188.     global gPrevAppTitle := "";        # Previous application title (for twitching back)
  189.     global gDisableAllLogging := 0;    # 1 if no logging (run time modify only)
  190.     if (global gDisableAllLogging)
  191.         Global gLogLevel := 0;
  192.     global gSFOriginalPath := {};    # Holds pathlist of Standard File before you navigate
  193.     
  194.     if(TypeOf(pTheScriptParam) = 'list')
  195.         SetTestLevel(pTheScriptParam[1],pTheScriptParam[2]);
  196.     else if(TypeOf(pTheScriptParam) = 'integer')
  197.     begin
  198.          if(pTheScriptParam = -1)        # Default setting for the scriptParam
  199.             SetTestLevel(1);            # Default to Quicklook
  200.         else
  201.             SetTestLevel(pTheScriptParam);
  202.     end;
  203.     
  204.     InitCustom();                    # Call to initalize any custom defined globals
  205.     InitRandomSeed();
  206. end;    
  207.  
  208. #########################################################################
  209. #                        InitRandomSeed()
  210. #========================================================================
  211. # Author:        ML
  212. # Description:    Initializes the random seed. 
  213. # Parameters:    None
  214. # Returns:        Nada
  215. # Examples:        InitRandomSeed();
  216. # Assumptions:    
  217. #========================================================================
  218. # History:
  219. #
  220. ########################################################################
  221. TASK InitRandomSeed()
  222. begin
  223.  
  224.     if global gSeedZero = 1            # if you want to seed 0
  225.         global gSeedValue:=0;
  226.     else                            # else non zero seed
  227.     begin
  228.         if not (gSeedValue)            # if you don't want to seed        
  229.             gSeedValue:= random();    # generate a random seed
  230.     end;
  231.     
  232.     randomseed(gSeedValue);            # seed the random number generator
  233.     
  234.     println "The seed value is ",gSeedValue;    # print out the seed value for posterity
  235.     
  236. end;    
  237.  
  238. #########################################################################
  239. #                            PrintGlobals()
  240. #========================================================================
  241. # Author:        NJV
  242. # Description:    Prints the values of all Control Globals
  243. # Parameters:    None
  244. # Returns:        Nothing
  245. # Examples:        PrintGlobals();
  246. # Assumptions:    None 
  247. #========================================================================
  248. # History:
  249. #
  250. #########################################################################
  251. TASK PrintGlobals() 
  252. begin
  253.  
  254.     if (global gAppVerify)
  255.         println "The 'Application Verification' scheme is turned - ON";
  256.     else
  257.         println "The 'Application Verification' scheme is turned - OFF";
  258.  
  259.     if (global gTargetCheck) 
  260.         println "The global 'gTargetCheck' is set to output - the title of the target's current 'Application'";
  261.     
  262.     ############## Print Font Globals ############
  263.     if (global gFontList) begin
  264.         print "The global 'gFontList' is : '";
  265.         fntCount := Card(gFontList);
  266.         For timeThru := 1 to fntCount begin
  267.             print gFontList[timeThru];
  268.             if     not(timeThru = fntCount)
  269.                 Print "', '";
  270.         end;
  271.         Println "'";
  272.     end;
  273.     
  274.     if (global gFontSizeList) begin
  275.         print "The global 'gFontSizeList' is : '";
  276.         fntSZCount := Card(gFontSizeList);
  277.         For timeThru := 1 to fntSZCount begin
  278.             print gFontSizeList[timeThru];
  279.             if     not(timeThru = fntSZCount)
  280.                 Print "', '";
  281.         end;
  282.         Println "'";
  283.     end;
  284.     
  285.     if (global gFontStyleList) begin
  286.         print "The global 'gFontStyleList' is : '";
  287.         fntSTLCount := Card(gFontStyleList);
  288.         For timeThru := 1 to fntSTLCount begin
  289.             print gFontStyleList[timeThru];
  290.             if     not(timeThru = fntSTLCount)
  291.                 Print "', '";
  292.         end;
  293.         Println "'";
  294.     end;
  295.     
  296.     if (global gTextStr) 
  297.         println "The global gTextStr is set to - '{gTextStr}'";
  298.             
  299.     ############## Print ScrapBook Globals ############
  300.     if (global kScrapTEXT) 
  301.         println "kScrapText is set to - '{kScrapTEXT}'";
  302.  
  303.     if (global kScrapPICT) 
  304.         println "kScrapPICT is set to - '{kScrapPICT}'";
  305.  
  306.     ############## Print Script Globals ############
  307.     if (global gAliasDirectory) 
  308.         println "gAliasDirectory is set to - '{gAliasDirectory}'";
  309.  
  310.     ############## Print Other Globals ############
  311.     if (global gLogLevel) 
  312.         println "gLogLevel is set to '{gLogLevel}'";
  313.     else
  314.         println "All logging is disabled";
  315.  
  316.     Println "The current system is - '{global gBuildVers}'";
  317.  
  318.     if (global gSFPUTLocation) 
  319.     begin
  320.         SFPath := "";
  321.         for each item in gSFPUTLocation 
  322.             SFPath := SFPath + Item + ":";
  323.         Println "SF_Put is set to navigate to '{SFPath}'";
  324.     end;
  325.     else
  326.         println "SF_Put will save to the default directory";
  327. end; # PrintGlobals()
  328. #########################################################################
  329. #                        BuildListFromResource( idNum )
  330. #========================================================================
  331. # Author:        Kevin Avoy (ext. 45604)
  332. # Description:    Returns a list generated from all of the strings in a specified
  333. #                string list resource <idNum>.
  334. # Parameters:    idNum := resource id number for the string list resource.
  335. # Returns:        list - all strings in specified string list resource.
  336. # Examples:        BuildListFromResource( 1000 ); 
  337. # Assumptions:    This task must be contained within the same file that contains
  338. #                the resources.
  339. #========================================================================
  340. # History:
  341. #
  342. #########################################################################
  343. task BuildListFromResource(idNum)
  344. begin
  345.     numtimes := 100;    #Assumes no resource will contain more than 100 strings
  346.     theList := {};
  347.     for i := 1 to numtimes
  348.     begin
  349.         CurrentItem := GetIndString(idNum,i);
  350.         #Println "This is the CurrentItem - ", CurrentItem;
  351.         if (isUndefined(CurrentItem))
  352.             numtimes := i;
  353.         else
  354.             theList := Insert(CurrentItem,Card(theList)+1, theList);
  355.     end;
  356.     #println "This is theList - ", theList;
  357.     return(theList);
  358. end;
  359.  
  360.  
  361. #########################################################################
  362. #            SetTestLevel(pTestLevel := 1, pCustomSetting := {})
  363. #========================================================================
  364. # Author:        Kevin Avoy (ext. 45604)
  365. # Description:    Will set globals that will determine the level of testing 
  366. #                that will occur in the DoTests.
  367. # Parameters:    pTestLevel := Generic level of testing desired.
  368. #                            1 - least amount of testing
  369. #                            2 - medium amount of testing
  370. #                            3 - Most amount of testing
  371. #                pCustomSetting - Any Custom settings, this will override the 
  372. #                                generic settings for any specified global setting.
  373. # Returns:        
  374. # Examples:        SetTestLevel( 1, {{'Draw', {1,2}}} ); 
  375. # Assumptions:    
  376. #========================================================================
  377. # History:
  378. # KTA    9/9/93    Added support for gAppTestLevel
  379. #########################################################################
  380. TASK SetTestLevel(pTestLevel := 1, pCustomSetting := {})
  381. begin
  382.     if(pTestLevel = 0)
  383.     begin
  384.         println "==== The test level is '{pTestLevel}' - (Turn all DoTests - OFF) =====";
  385.         
  386.         global gFontLevel := 0;
  387.         global gDrawLevel := 0;
  388.         global gWindowLevel := 0;
  389.         global gAppTestLevel := 0;
  390.     end;
  391.     else if(pTestLevel = 1)
  392.     begin
  393.         println "==== The test level is '{pTestLevel}' - (Minimum amount of testing) =====";
  394.         
  395.         global gFontLevel := 1;
  396.         global gDrawLevel := 1;
  397.         global gWindowLevel := 1;
  398.         global gAppTestLevel := 1;
  399.     end;
  400.     else if(pTestLevel = 2)
  401.     begin
  402.         println "==== The test level is '{pTestLevel}' - (Medium amount of testing) =====";
  403.         
  404.         global gFontLevel := 2;
  405.         global gDrawLevel := 2;
  406.         global gWindowLevel := 2;
  407.         global gAppTestLevel := 2;
  408.     
  409.     end;
  410.     else if( pTestLevel = 3)
  411.     begin
  412.         println "==== The test level is '{pTestLevel}' - (Most amount of testing) =====";
  413.         
  414.         global gFontLevel := {2,3};
  415.         global gDrawLevel := {2,3};
  416.         global gWindowLevel := {2,3};
  417.         global gAppTestLevel := 3;
  418.     end;
  419.     
  420.     
  421.     if (pCustomSetting)
  422.     begin
  423.         for each testLevel in pCustomSetting
  424.         begin
  425.             whichMethod := testLevel[1];
  426.             testsettings := testLevel[2];
  427.             if(whichMethod = 'DrawLevel')
  428.             begin
  429.                 println "    Custom gDrawLevel := {testsettings}";
  430.                 global gDrawLevel := testsettings;
  431.             end;
  432.             else if(whichMethod = 'FontLevel')
  433.             begin
  434.                 println "    Custom gFontLevel := {testsettings}";
  435.                 global gFontLevel := testsettings;
  436.             end;
  437.             else if(whichMethod = 'WindowLevel := {testsettings}')
  438.             begin
  439.                 println "    Custom gWindowLevel";
  440.                 global gWindowLevel := testsettings;
  441.             end;
  442.             else if(whichMethod = 'AppTestLevel')
  443.             begin
  444.                 println "    Custom gAppTestLevel := {testsettings}";
  445.                 global gAppTestLevel := testsettings;
  446.             end;
  447.         end;
  448.     end;
  449. end;
  450.  
  451. #########################################################################
  452. #                            ExitVU()
  453. #========================================================================
  454. # Author:        Kevin Avoy
  455. # Description:    This task makes the built in VU task Exit.  The purpose
  456. #                of defining this as a task is so we can use a task 
  457. #                reference to this task- gExitVu.  This way we can default 
  458. #                our Exception Handling task to call the task reference gExitVU 
  459. #                and thus exit. If others do not want to exit they can redefine 
  460. #                the task reference to what ever task they prefer.
  461. # Parameters:    None
  462. # Returns:        Nothing
  463. # Examples:        ExitVU(); or to use the task reference  - Call(global gExitVU);
  464. # Assumptions:    Note: gExitVU is defined in Globals.lib.  If you want to 
  465. #                override this task reference please do not modify Globals.Lib,
  466. #                override the it by redefining it in Custom.Lib.
  467. #########################################################################
  468. #========================================================================
  469. # History:
  470. #########################################################################
  471. TASK ExitVU()
  472. begin
  473.     exit;
  474. end;
  475.